package com.datalayer.utils;

/**
 * Created with IntelliJ IDEA.
 * User: Georgiana.Scarlat
 * Date: 7/5/12
 * Time: 11:06 AM
 */


public class Pair<X, Y> {

    private X first;
    private Y second;

    public Pair() {
    }

    public Pair(X first, Y second) {
        this.first = first;
        this.second = second;
    }

    public Y getSecond() {
        return second;
    }

    public X getFirst() {

        return first;
    }


    @Override
    public String toString() {
        return "Pair{" +
                "first=" + first +
                ", second=" + second +
                '}';
    }


    @SuppressWarnings("unchecked")
    public <T> void add(T obj) {
        if (first == null)
            this.first = (X) obj;
        else
            this.second = (Y) obj;
    }

    public <T> boolean contains(T obj) {

        return obj.equals(first) || obj.equals(second);
    }

}
